import {
	defineConfig,
} from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import AutoImport from 'unplugin-auto-import/vite';
import vue from '@vitejs/plugin-vue';
import ENV_CONFIG from "./config/envConfig.js"

import {
	resolve
} from 'path'

function pathResolve(dir) {
	return resolve(__dirname, ".", dir);
}

export default defineConfig(({
	command,
	mode
}) => {

	return {
		plugins: [
			uni(),
			AutoImport({
				imports: [
					'vue',
					'uni-app',
					'pinia',
					{
						'uni-mini-router': ['useRouter', 'useRoute'],
					},
				]
			})
		],
		define: {
			'process.env.config': ENV_CONFIG,
		},
		resolve: {
			alias: {
				"@p": pathResolve("page"),
				"@c": pathResolve("components"),
				"@sto": pathResolve("store"),
				"@sta": pathResolve("static"),
				"@u": pathResolve("until"),
				"@config": pathResolve("config"),
			}
		},

	}
})